/**
 * 逆时针正五边形ABCDE
 * 给定两条线段，问长度是否相等
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;

using llt = long long;
using vi = vector<int>;


int f(string s){
    int t = s[1] - s[0];
    if(t < 0) t += 5;
    if(t >= 3) t = 5 - t;
    return t;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0);
    int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--){
        string a, b; cin >> a >> b;
        cout << (f(a) == f(b) ? "Yes" : "No") << endl;
    }
    return 0;
}